<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../org/angular.min.js"></script>
</head>
<body>
    <div ng-app="vm" ng-controller="ctrl">
       <table border="1" width="600px">
           <tr>
               <td ng-click="orderBy('id')">编号
                   <span ng-if="status.id">升序</span>
                   <span ng-if="!status.id">降序</span>
               </td>
               <td ng-click="orderBy('click')">点击数
                   <span ng-if="status.click">升序</span>
                   <span ng-if="!status.click">降序</span>
               </td>
               <td ng-click="orderBy('title')">标题
                   <span ng-if="status.title">升序</span>
                   <span ng-if="!status.title">降序</span>
               </td>
           </tr>
           <tr ng-repeat="(k,v) in data">
               <td>{{v.id}}</td>
               <td>{{v.click}}</td>
               <td>{{v.title}}</td>
           </tr>
       </table>
    </div>
    <script>
        var vm = angular.module('vm',[]);
        vm.controller('ctrl',['$scope','$filter',function($scope,$filter){
           $scope.data = [
               {id: 1,click: 100,title: '后盾人'},
               {id: 2,click: 200,title: 'PHP'},
               {id: 3,click: 300,title: '后盾网'}
           ]
           //设置默认排序状态
           $scope.status = {id: false,click: false,title: false }
           $scope.orderBy = function(type){
               console.log(type)
               $scope.status[type] = !$scope.status[type];
               console.log($scope.status[type])
               $scope.data = $filter('orderBy')($scope.data,type,$scope.status[type])
           }
        }])
    </script>
</body>
</html>